<template>
    <div class="default-main ba-table-box">
        <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />

        <!-- 表格顶部菜单 -->
        <TableHeader
            :buttons="mainOperate=='view'?[]:['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
            :quick-search-placeholder="t('quick Search Placeholder', { fields: t('conloadplan.quick Search Fields') })"
        />

        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table ref="tableRef" />

        <!-- 表单 -->
        <PopupForm />
    </div>
</template>

<script setup lang="ts">
import { ref, provide, onMounted, inject } from 'vue'
import baTableClass from '/@/utils/baTable'
import { conloadplan } from '/@/api/controllerUrls'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'
import { useI18n } from 'vue-i18n'
import PopupForm from './popupForm.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'


const TZID = inject('TZID')
const mainOperate = inject('mainOperate')

const { t } = useI18n()
const tableRef = ref()
const optButtons = defaultOptButtons(["edit","delete"])
const baTable = new baTableClass(
    new baTableApi(conloadplan),
    {
        pk: 'CONLOADPLANID',
        column: [
            { type: 'selection', align: 'center', operator: false },
            // { label: t('conloadplan.CONLOADPLANID'), prop: 'CONLOADPLANID', align: 'center' },
            // { label: t('conloadplan.TZID'), prop: 'TZID', align: 'center' },
            { label: t('conloadplan.CNTRNO'), prop: 'CNTRNO', align: 'center' },
            { label: t('conloadplan.SEALNO'), prop: 'SEALNO', align: 'center' },
            { label: t('conloadplan.HCPLACE'), prop: 'HCPLACE', align: 'center' },
            { label: t('conloadplan.FREESTORAGEFROM'), prop: 'FREESTORAGEFROM', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            { label: t('conloadplan.PACKERDESC'), prop: 'PACKERDESC', align: 'center' },
            { label: t('conloadplan.ZHDATE'), prop: 'ZHDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            { label: t('conloadplan.TXPLACE'), prop: 'TXPLACE', align: 'center' },
            { label: t('conloadplan.SHPLACE'), prop: 'SHPLACE', align: 'center' },
            
            // { label: t('conloadplan.CONSIZE'), prop: 'CONSIZE', align: 'center' },
            // { label: t('conloadplan.CONTYPE'), prop: 'CONTYPE', align: 'center' },
            // { label: t('conloadplan.PACKERPHONE'), prop: 'PACKERPHONE', align: 'center' },
            // { label: t('conloadplan.PACKERDATE'), prop: 'PACKERDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('conloadplan.PACKER'), prop: 'PACKER', align: 'center' },
            // { label: t('conloadplan.EMPTY'), prop: 'EMPTY', align: 'center' },
            // { label: t('conloadplan.PKGS'), prop: 'PKGS', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.GWET'), prop: 'GWET', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.SUMSIZE'), prop: 'SUMSIZE', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.DESCRIPTION'), prop: 'DESCRIPTION', align: 'center' },
            // { label: t('conloadplan.TRUCKCORP'), prop: 'TRUCKCORP', align: 'center' },
            // { label: t('conloadplan.DRIVER'), prop: 'DRIVER', align: 'center' },
            // { label: t('conloadplan.TRUCKNO'), prop: 'TRUCKNO', align: 'center' },
            // { label: t('conloadplan.CONCORP'), prop: 'CONCORP', align: 'center' },
            // { label: t('conloadplan.COC'), prop: 'COC', align: 'center' },
            // { label: t('conloadplan.TAREWT'), prop: 'TAREWT', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.TOTALWT'), prop: 'TOTALWT', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.FCL'), prop: 'FCL', align: 'center' },
            // { label: t('conloadplan.MIXNO'), prop: 'MIXNO', align: 'center' },
            // { label: t('conloadplan.MIXSUM'), prop: 'MIXSUM', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.OP'), prop: 'OP', align: 'center' },
            // { label: t('conloadplan.OPTIME'), prop: 'OPTIME', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('conloadplan.REMARK'), prop: 'REMARK', align: 'center' },
            // { label: t('conloadplan.LOADREMARK'), prop: 'LOADREMARK', align: 'center' },
            // { label: t('conloadplan.LOADBILLREMARK'), prop: 'LOADBILLREMARK', align: 'center' },
            // { label: t('conloadplan.TRANSITEM'), prop: 'TRANSITEM', align: 'center' },
            // { label: t('conloadplan.OCEANTRANSITEM'), prop: 'OCEANTRANSITEM', align: 'center' },
            // { label: t('conloadplan.FREESTORAGETO'), prop: 'FREESTORAGETO', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('conloadplan.HCDATE'), prop: 'HCDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('conloadplan.DISTANCE'), prop: 'DISTANCE', align: 'center', operator: 'RANGE' },
            // { label: t('conloadplan.SHDATE'), prop: 'SHDATE', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            // { label: t('conloadplan.TRAILERNO'), prop: 'TRAILERNO', align: 'center' },
            { label: t('operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, show:mainOperate.value!=='view' ,operator: false },
        ],
        dblClickNotEditColumn: [undefined, ],
        defaultOrder: { prop: 'CONLOADPLANID', order: 'desc' },
    },
    {
        defaultItems: [],
    }
)

provide('baTable', baTable)


onMounted(() => {
    baTable.table.ref = tableRef.value
    baTable.table.filter!.TZID = TZID.value||''
    console.log(TZID,mainOperate.value)
    baTable.mount()
    baTable.getIndex()?.then(() => {
        baTable.initSort()
        baTable.dragSort()
    })
})
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'conloadplan',
})
</script>

<style scoped lang="scss"></style>
